<?php

/**
 * ListDocumentTypes form.
 *
 * @package    form
 * @subpackage list_document_types
 * @version    SVN: $Id: sfPropelFormTemplate.php 6174 2007-11-27 06:22:40Z fabien $
 */
class ListDocumentTypesForm extends BaseListDocumentTypesForm
{
  public function configure()
  {
    $this->widgetSchema->setLabels(
      array(
        'type_tag'=>'Type:',
        'typeid'=>'Prefix:',
        'type_name'=>'Name:',
        'last_id'=>'Last ID:',
      )
    );
    
    if($this->isNew())
      $this->validatorSchema['iden'] = new sfValidatorString(array('required' => true));
    $this->widgetSchema['typeid']->setAttributes(array('size'=>5));
    $this->widgetSchema['type_name']->setAttributes(array('size'=>20));
    $this->widgetSchema['last_id']->setAttributes(array('size'=>5));
    
    $this->widgetSchema['type_tag'] = 
      new sfWidgetFormSelect(
        array(
          'choices'=>
          array_combine(
            sfConfig::get('app_selection_document_type_tags'),
            sfConfig::get('app_selection_document_type_tags')
          ),
        )
      );
    
    $this->validatorSchema['type_tag']->setOption('min_length',1);
    $this->validatorSchema['last_id']->setOption('required',false);
    $this->validatorSchema['last_id']->setOption('min_length',1);
    $this->validatorSchema['typeid']->setOption('min_length',1);
    $this->validatorSchema['type_name']->setOption('min_length',5);
    
    
  }
  
  public function getUrl(){
    if($this->isNew())
      return 'document_types/insert';
    else
      return 'document_types/update';
  }
  
  public function getDeleteUrl(){
    return 'document_types/delete?iden='.$this->getObject()->getIden();
  }
  
  public function getEditUrl(){
    return 'document_types/edit?iden='.$this->getObject()->getIden();
  }
  
}
